package com.atguigu.ssyx.order.controller;


import com.atguigu.ssyx.common.auth.AuthContextHolder;
import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.model.order.OrderInfo;
import com.atguigu.ssyx.order.service.OrderInfoService;
import com.atguigu.ssyx.vo.order.OrderQueryVo;
import com.atguigu.ssyx.vo.order.OrderUserQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping(value="/admin/order")
public class OrderAdminController {


    @Autowired

    private OrderInfoService  orderInfoService;

    //订单查询
    @GetMapping("orderInfo/{page}/{limit}")
    public Result OrderAdminListPage(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Long page,
            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Long limit,
            @ApiParam(name = "orderVo", value = "查询对象", required = false)
            OrderQueryVo orderQueryVo) {

        //分页查询条件
        Page<OrderInfo> pageParam = new Page<>(page,limit);
        IPage<OrderInfo> pageModel = orderInfoService.OrderAdminListPage(pageParam,orderQueryVo);
        return Result.ok(pageModel);
    }

    @GetMapping("orderInfo/get/{orderId}")
    public Result OrderAdminListById(@PathVariable("orderId")  Long orderId){

        OrderInfo orderInfo = orderInfoService.OrderAdminListById(orderId);
        return Result.ok(orderInfo);
    }

}
